<template>
  <div class="conall">
    <el-container style="height: 84vh; border: 1px solid #eee">
      <el-aside width="200px" style="background-color: rgb(238, 241, 246) ">
        <el-menu
          :default-openeds="['1']"
          :default-active="activeindex"
          @select="handleSelect"
          router
        >
          <el-submenu index="1">
            <template slot="title">
              <i class="el-icon-user"></i>会员管理
            </template>
            <el-menu-item index="/UserList">会员列表</el-menu-item>
            <el-menu-item index="/UserHot">会员记录</el-menu-item>
            <el-menu-item index="/UserAnalyse">会员分析</el-menu-item>
          </el-submenu>

          <el-submenu index="2" v-if="isroot">
            <template slot="title">
              <i class="el-icon-chicken"></i>教练管理(root)
            </template>
            <el-menu-item index="/CoachList">教练列表</el-menu-item>
            <el-menu-item index="/CoachAnalyse">教练分析</el-menu-item>
          </el-submenu>

          <el-submenu index="3"  v-if="isroot">
            <template slot="title">
              <i class="el-icon-s-cooperation"></i>器械管理(root)
            </template>
            <el-menu-item index="/MachineList">器械列表</el-menu-item>
            <el-menu-item index="/MachineHot">器械分析</el-menu-item>
          </el-submenu>

          <el-submenu index="4" v-if="isroot">
            <template slot="title">
              <i class="el-icon-lock"></i>权限管理(root)
            </template>
            <el-menu-item index="/adminlist">权限用户</el-menu-item>
          </el-submenu>
          <el-submenu index="5" v-if="isroot">
            <template slot="title">
              <i class="el-icon-tickets"></i>账单(root)
            </template>
            <el-menu-item index="/Income">盈利</el-menu-item>
          </el-submenu>
          <el-submenu index="6" v-if="isroot">
            <template slot="title">
              <i class="el-icon-cpu"></i>监控系统(root)
            </template>
            <el-menu-item index="/monitor">控制面板</el-menu-item>
          </el-submenu>
          <el-submenu index="7" v-if="isroot">
            <template slot="title">
              <i class="el-icon-setting"></i>系统(root)
            </template>
            <el-menu-item index="/syslog">系统日志</el-menu-item>
            <el-menu-item index="/sysreset">系统重置</el-menu-item>
          </el-submenu>
        </el-menu>
      </el-aside>

      <el-container style="background-color: rgb(238, 241, 246)">
        <el-main>
          <router-view name="mian"></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>
<script>
export default {
  name: "MainCon",
  props: ["username"],
  data() {
    return {
      isroot: false,
      activeindex: "/UserList"
    };
  },

  methods: {
    handleSelect(key, keyPath) {
      console.log(key, keyPath);
    }
  },
  created() {
    // console.log(this.$route.path);
    if (this.$route.path != "/UserList") {
      this.$router.push("/UserList");
    }
    this.$axios
      .post("http://47.108.248.93:999/tokenLogin", window.localStorage.getItem("token"))
      .then(res => {
        console.log(res.data);
        if (res.data.data == "root") {
          this.isroot = true;
        } else {
          this.isroot = false;
        }
      });
  }
};
</script>
<style scoped>
</style>
